<template>
	<div class="confirmPresult">
		<el-breadcrumb separator-class="el-icon-arrow-right" style="margin-bottom:15px;">
            <el-breadcrumb-item :to="{ path: '/tobepaidlist' }">待支付清单</el-breadcrumb-item>
            <el-breadcrumb-item>人工确认支付结果</el-breadcrumb-item>
        </el-breadcrumb>
        <el-form ref="ruleForm" :model="params" :rules="rules" class="demo-form-inline" style="margin-bottom:15px;margin-top: 50px" label-width="150px">
			<div style="display: flex;">
				<div>
					<el-form-item label="确认支付结果：" prop="payStatus">
						<el-select v-model="params.payStatus"  size="small">
							<el-option v-for="(item,index) in resultts" :label="item.label" :key="index" :value="item.value"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="付款金额：" prop="payeeAmount">
						<el-input size="small" v-model="params.payeeAmount" placeholder="请输入付款金额" style="width:217px;"></el-input>
					</el-form-item>
					<el-form-item label="支付时间：" prop="payTime">
						<el-date-picker  size="small"
							v-model="params.payTime"
							type="date"
							placeholder="选择日期">
						</el-date-picker>
					</el-form-item>
					<el-form-item label="收款方名称：" prop="payeeName">
						<el-input size="small" v-model="params.payeeName" placeholder="请输入收款方名称" style="width:217px;"></el-input>
					</el-form-item>
				</div>
				<div>
					<el-form-item label="收款方账号：" prop="payeeAccountNumber">
						<el-input size="small" v-model="params.payeeAccountNumber" placeholder="请输入收款方账号" style="width:217px;"></el-input>
					</el-form-item>
					<el-form-item label="付款方名称：" prop="payerName">
						<el-select v-model="params.payerName" filterable @change="loadpayerAccount">
							<el-option v-for="(item,index) in payerNames" :label="item.companyName" :value="item.companyName" :key="index"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="付款方账号：" prop="payerAccountNumber">
						<el-select v-model="params.payerAccountNumber" filterable>
							<el-option v-for="(item,index) in payerAccountNumbers" :label="item.bankAccount" :value="item.bankAccount" :key="index"></el-option>
						</el-select>
					</el-form-item>
				</div>
			</div>
			<el-form-item label="支付结果说明：" prop="remark">
				<el-input size="small" style="width:50%;" type="textarea" :rows="6" placeholder="请输入支付结果说明" v-model="params.remark" maxlength="150" show-word-limit ></el-input>
			</el-form-item>
			<div style="width: 54%;text-align: right;">
				<el-button type="default" @click="cancelPay">取消</el-button>
				<el-button type="primary" @click="confirmPay">确认</el-button>
			</div>	
        </el-form>
	</div>
</template>

<script>
	export default {
		data(){
			return {
				code:this.$route.query.code,
				resultts:[
					{value:3,label:"支付成功"}
				],
				payerNames:[

				],
				payerAccountNumbers:[
					
				],
				params:{
					pushCode:"",
					payStatus:3,
					payStatus:"",//确认支付结果
					payeeAmount:"",//付款金额
					payTime:"",//支付时间
					payeeName:"",//收款方名称
					payeeAccountNumber:"",//收款方账号
					payerName:"",//付款方名称
					payerAccountNumber:"",//付款方账号
					remark:"",//支付结果说明
				},
				rules:{
					payStatus:[{required: true, message: '请选择确认支付结果', trigger: 'change'}],
					payeeAmount:[{required: true, message: '请输入付款金额', trigger: 'blur'}],
					payTime:[{required: true, message: '请选择支付时间', trigger: 'blur'}],
					payeeName:[{required: true, message: '请输入收款方名称', trigger: 'blur'}],
					payeeAccountNumber:[{required: true, message: '请输入', trigger: 'blur'}],
					payerName:[{required: true, message: '请选择付款方名称', trigger: 'change'}],
					payerAccountNumber:[{required: true, message: '请选择付款方账号', trigger: 'change'}],
					remark:[{required: true, message: '请输入支付结果说明', trigger: 'blur'}]
				}
			}
		},
		methods:{
			loadData(){
				this.$axios.post(`/kingdee/payList/selectByCode`,{code:this.code}).then(res => {
	                this.params.payeeAmount=res.payAmount;
	                this.params.payeeName=res.recName;
	                this.params.payeeAccountNumber=res.recAccNo;
	                this.params.payerName=res.paymentName;
	                this.params.payerAccountNumber=res.paymentAccNo;
	                this.params.pushCode=res.code;
	            });
			},
			confirmPay(){
				this.$refs["ruleForm"].validate((valid)=>{
					if(!valid){
						return;
					}
					this.params.payTime=new Date(this.params.payTime).getTime();
					this.$axios.post(`/kingdee/payList/confirmPayResult`,this.params).then(res => {
		                this.$message({
							message: '操作成功',
							showClose: true,
							type: 'success',
							onClose:()=>{
		                        this.$router.push({
		                        	path:"/tobepaidlist"
		                        })
							}
						});
		            });
				})
			},
			loadBankData(){
				this.$axios.post(`/contract/api/contractUndersign/getInside`,{}).then(res => {
	                this.payerNames=res;
	            });
			},
			loadpayerAccount(val){
				this.payerAccountNumbers=[];
				this.params.payerAccountNumber="";
				for(let i=0;i<this.payerNames.length;i++){
					if(val==this.payerNames[i].companyName){
						this.payerAccountNumbers=this.payerNames[i].bank;
					}
				}
			},
			cancelPay(){
				this.$router.push({
					path:"/tobepaidlist"
				})
			}
		},
		mounted(){
			this.loadData();
			this.loadBankData();
		}
	}
</script>

<style>
	
</style>
